#ifndef LONGKEY_COMMON_USER_INFO_H_
#define LONGKEY_COMMON_USER_INFO_H_

#include <Windows.h>
#include <atlstr.h>
#include <atlsecurity.h>

namespace user_info
{
	// Gets the user name, domain, and the SID associated with the access token
	// of the current process.
	HRESULT GetProcessUser(CString* name, CString* domain, CString* sid);

	// Gets SID associated with the access token of the current process.
	HRESULT GetProcessUserSid(CSid* sid);

	// Gets the user SID associated with the access token of the current thread if
	// the thread is impersonating. If the thread is not impersonating, the API
	// fails with ERROR_NO_TOKEN.
	HRESULT GetThreadUserSid(CString* sid);

	// Gets the user SID associated with the access token of the current thread if
	// the thread is impersonating. Otherwise, gets the SID associated with the
	// access token of the current process.
	HRESULT GetEffectiveUserSid(CString* sid);

	// TODO: deprecate weird API.
	// Looks at the current user SID and checks if it's the same as the
	// LocalSystem user.
	HRESULT IsLocalSystemUser(bool* is_local_system,
		CString* user_sid);     // optional.

	// Returns true if the caller's impersonation or process access token user
	// is LOCAL_SYSTEM.
	bool IsRunningAsSystem();

	// Returns true if the current thread is impersonating.
	bool IsThreadImpersonating();
}

#endif	// LONGKEY_COMMON_USER_INFO_H_